import { ipcRenderer } from 'electron-better-ipc'
import { ILanhuJsonRes, Info } from './lanhuTypes'
import { Version } from './lanhuTypes2'

export interface IDesignDataItem {
    // id
    id: string
    // 版本
    latestVersionId: string
    // 名称
    name: string
    // 版本详情
    version: Version
    // json数据，其中没有info
    jsonData: ILanhuJsonRes
    // info数据
    infos: Info[]
}

// 读取设计稿数据
export const readDesignData = async (workSpaceId: string) => {
    return await ipcRenderer.callMain<string, IDesignDataItem[]>('readDesignData', workSpaceId)
}
// 保存
export const saveDesignData = async (data: { workSpaceId: string; data: IDesignDataItem[] }) => {
    console.log(`ipcRenderer.callMain('saveDesignData', data)`, data)
    return await ipcRenderer.callMain('saveDesignData', data)
}
